package com.sambo.inspection.bean;

import android.text.TextUtils;

import com.sambo.inspection.util.SpUtil;

public class GlobleBean {

    private static GlobleBean sGlobleBean;

    private int userID;
    private String userName;
    private String accessToken;
    private String phone;
    private String nickName;
    private String mail;
    private String deptID;
    private long lastMessageTS;

    private GlobleBean() {

    }

    public static GlobleBean getInstance() {
        if (sGlobleBean == null) {
            sGlobleBean = new GlobleBean();
        }
        return sGlobleBean;
    }

    public int getUserID() {
        return userID;
    }

    public void setUserID(int userID) {
        if (this.userID != userID) {
            this.userID = userID;
            SpUtil.setUserID(userName, userID);
        }
    }

    public String getUserName() {
        return userName;
    }

    public void  setUserName(String userName) {
        this.userName = userName;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        if (!TextUtils.equals(this.phone, phone)) {
            this.phone = phone;
            SpUtil.setPhone(userName, phone);
        }
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        if (!TextUtils.equals(this.nickName, nickName)) {
            this.nickName = nickName;
            SpUtil.setNickName(userName, nickName);
        }
    }

    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        if (!TextUtils.equals(this.mail, mail)) {
            this.mail = mail;
            SpUtil.setMail(userName, mail);
        }
    }

    public String getDeptID() {
        return deptID;
    }

    public void setDeptID(String deptID) {
        if (!TextUtils.equals(this.deptID, deptID)) {
            this.deptID = deptID;
            SpUtil.setDeptID(userName, deptID);
        }
    }

    public long getLastMessageTS() {
        return lastMessageTS;
    }

    public void setLastMessageTS(long lastMessageTS) {
        if (this.lastMessageTS != lastMessageTS) {
            this.lastMessageTS = lastMessageTS;
            SpUtil.setLastMessageTS(userName, lastMessageTS);
        }
    }
}
